/* 文章相关的接口 */

// 一、导入axios
import axios from '@/utils/request'

// 二、导出方法
// 2.1 获取文章的方法
export const getArticle = (channelId, timestamp) => {
  return axios({
    method: 'get',
    url: '/v1_1/articles',
    params: {
      with_top: 1,
      channel_id: channelId,
      timestamp,
    },
  })
}

// 2.2 不感兴趣操作的方法
export const postDislike = articleId => {
  return axios({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId,
    },
  })
}

// 2.3 举报操作的方法
export const postReport = (articleId, type) => {
  return axios({
    method: 'post',
    url: '/v1_0/article/reports',
    data: {
      target: articleId,
      type,
    },
  })
}

// 2.4 获取文章详情的方法
export const getArticlDetail = articleId => {
  return axios({
    method: 'get',
    url: `/v1_0/articles/${articleId}`,
  })
}

// 2.5 对文章点赞
export const postLike = articleId => {
  return axios({
    method: 'post',
    url: '/v1_0/article/likings',
    data: {
      target: articleId,
    },
  })
}

// 2.6 取消点赞
export const deleteLike = articleId => {
  return axios({
    method: 'delete',
    url: `/v1_0/article/likings/${articleId}`,
    data: {
      target: articleId,
    },
  })
}

// 2.7 对文章不喜欢
export const postDislikes = articleId => {
  return axios({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId,
    },
  })
}

// 2.8 对文章取消不喜欢
export const deleteDislikes = articleId => {
  return axios({
    method: 'delete',
    url: `/v1_0/article/likings/${articleId}`,
  })
}
